package com.hunglv.ppn;

import com.hunglv.ppn.database.DatabaseHelper;

import android.os.Bundle;
import android.app.Activity;
import android.database.Cursor;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {	
	Button showBtn;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        showBtn = (Button)findViewById(R.id.showBtn);
        showBtn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				DatabaseHelper mDatabaseHelper = new DatabaseHelper(MainActivity.this);
				mDatabaseHelper.open();
				
				if(mDatabaseHelper != null){
					Cursor result = mDatabaseHelper.getAllSmsCursor();
					if(result.moveToFirst()){
						do{
							String content = result.getString(DatabaseHelper.COLUMN_CONTENT);
							long time = result.getLong(DatabaseHelper.COLUMN_TIME);
							Log.v("Content", content+" "+time);
						}while(result.moveToNext());
					}
				}
				mDatabaseHelper.close();
			}
		});
    }

    @Override
    public void onDestroy(){
    	super.onDestroy();
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    
}
